package 领扣算法.力扣计划.算法基础.乘积小于K的子数组;

public class Main {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        long middle=0;
        int i=0;
        while (i<nums.length&&nums[i]>=k) {
            i++;
        }
        int res=0;
        for (;  i<nums.length ; i++) {
            middle=nums[i];
            if (k>middle)
                res++;
            for (int j = i+1; j < nums.length; j++) {
                middle*=nums[j];
                if (k>middle)
                    res++;
                else {
                    break;
                }
            }

        }
        return res;

    }
}
